
<div class="header">
    <a href="index.php?act=member" class="return iconfont icon-shangyiye"></a>
    <div class="header-title">活动订单</div>
</div>
<div class="content content-bot">
    <ul class="categoryson-title">
        <a href="index.php?act=merchant&op=activity&state=20"><li class="<?php echo $output['state'] == 20 ? 'active' : ''; ?>">待消费</li></a>
        <a href="index.php?act=merchant&op=activity&state=21"><li class="<?php echo $output['state'] == 21 ? 'active' : ''; ?>">已消费</li></a>
    </ul>
    <div class="recommend-list activity-list">
        <ul class="commodity-wraw">
            <?php if (!empty($output['orders'])): ?>
            <?php foreach ($output['orders'] as $order): ?>
            <a href="index.php?act=merchant&op=actdetail&ordersn=<?php echo $order['bg_order_sn']; ?>">
            <li>
                <div class="go-title">发起者：<samp><?php echo $order['nickname']; ?></samp><span>时间：<?php echo date('Y/m/d', $order['pay_time']); ?></span></div>
                <div class="commodity">
                    <div class="commodity-img">
                        <img src="<?php echo $order['bg_thumb']; ?>" />
                    </div>
                    <div class="commodity-con">
                        <div class="commodity-title"><?php echo $order['bg_title']; ?></div>
                        <div class="commodity-code">¥<?php echo $order['bg_order_price']; ?></div>
                        <div class="commodity-price">
                            <?php if ($output['state'] == 20): ?>
                            <div class="commodity-state">券码：<?php echo substr($order['bg_order_code'],0,10).str_repeat('x',6); ?></div>
                            <?php else: ?>
                            <div class="commodity-state">券码：<?php echo $order['bg_order_code']; ?></div>
                            <?php endif; ?>
                        </div>
                    </div>
                    <div class="clear"></div>
                </div>
            </li>
            </a>
            <?php endforeach; ?>
            <?php else: ?>
                <div class="empty">暂无内容</div>
            <?php endif; ?>
        </ul>
        <div class="clear"></div>
    </div>
    <div class="load hide">正在加载...</div>
</div>
<script>
    var allNum = <?php echo $output['TotalNum']; ?>,
        allPage = <?php echo $output['TotalPage']; ?>,
        curPage = 1;

    var is_scroll = false;
    //ajax加载数据
    function loadpage() {
        if(!is_scroll){
            return;
        }
        if (curPage < allPage) {
            curPage += 1;
        } else {
            $('.load').text('没有更多内容了').show();
            return;
        }
        $.get(location.href, {isajax:1,curpage:curPage},function(data){
            if(data){
                $(".activity-list > ul").append(data);
                $('.load').hide();
            }
        });
    }
    $(window).scroll(function () {
        $('.load').show();
        is_scroll = true;
        //已经滚动到上面的页面高度
        var scrollTop = $(this).scrollTop();
        //页面高度
        var scrollHeight = $(document).height();
        //浏览器窗口高度
        var windowHeight = $(this).height();
        //此处是滚动条到底部时候触发的事件，在这里写要加载的数据，或者是拉动滚动条的操作
        if (scrollTop + windowHeight == scrollHeight) {
            loadpage();
        }
    });
</script>
